1. Technical Field
The present invention relates to the field of memory, and more particularly, to an allocation method and apparatus of moderate memory.
2. Description of Related Art
One of the typical microcontrollers is comprised as shown in FIG. 1. Generally, physical memory is managed by an operating system (OS) through Memory Management Unit (MMU), and application programs are run based on logical address space instead of accessing physical memory directly.
The physical memory typically is managed in form of paging according to modern OS where page size of the physical memory, exemplarily, may be 1 Kbyte, 4 Kbyte, 16 Kbyte and 1 Mbyte. Generally, when an application program is created, one page of physical memory is allocated and mapped into the logical address space of the application program by the OS. If the logical address of the page accessed by the application program isn't in the physical memory, a certain exception will be caused. After the exception handler of the OS allocates one free page to the application program and makes page mapping between the page and the logical address space, the application program can be run continually.
In an embedded system, it is necessary that data is exchanged directly (including writing data into memory and reading data from memory) between some devices inside or outside of embedded chip and memory, i.e. Direct Memory Access (DMA), in which MMU is not required. Therefore the page mapping executed by the microcontrollers is imperceptible and the devices need to access successive physical address space directly.
In an electronic system, memory generally is used as execution space of programs. The code segment, the data segment, the stack space of the programs and so on run in the memory. It doesn't allow 1 bit or more than 1 bit damage in the memory for storing code segment, otherwise the instruction code stored in the damaged bits is changed, and unpredictable errors may occur when the instruction code is executed. However, the flow errors of the programs may not occur when there is some damage in the memory for storing the data segment and the stack space. It at most, for example, brings in an abnormal pixel in a display if the data on damaged bits are just the data used for output to the display. However, if the damaged data relates to a condition for the execution of a program, the damaged data will cause the flow errors of the program.
In summary, an electronic system may be compatible with moderate memory, wherein the moderate memory refers to the memory having defective bits. In prior art, almost all of the methods accommodate moderate memory in the form of hardware, i.e. by partitioning the address wire or data wire so that high-capacity memory is “degraded” into small-capacity memory for use or abstracting a plurality of moderate memory pieces into one integral memory piece. However, those methods accommodating moderate memory are costly and the efficiency of moderate memory is low.